package com.spring.theory.mvc.controller;

import com.spring.theory.mvc.adapter.resolver.Token;
import com.spring.theory.mvc.adapter.resolver.Yml;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@Controller
@Slf4j
public class TestController {
    @GetMapping("/test1")
    public ModelAndView test1() throws Exception {
        log.info("test1()");
        return null;
    }

    @PostMapping("/test2")
    public ModelAndView test2(@RequestParam("name") String name) {
        log.info("test2({})", name);
        return null;
    }

    @PutMapping("/test3")
    public ModelAndView test3(@Token String token) {
        log.info("test3({})", token);
        return null;
    }

    @RequestMapping("/test4")
    @Yml
    public Uer test4() {
        return new Uer("123", "123");
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @ToString
    static class Uer {
        private String name;
        private String password;
    }

}
